import {MenuObjPropNameEnum, useMenuStore} from '@menu'
import {
  IptPropsConstType,
  PageOptionsConst,
  CommonIptOptionsConst,
  CommonSwitchIptTextConst,
  CommonIptPropValConst,
} from '@config'
import {MenuIptLimit} from './menu-ipt-limit.ts'
import {MenuTypeOptionsConst} from './menu-type-options-const.ts'
import {MenuIconTypeOptions} from './menu-icon-type-options.ts'

/**
 * 与菜单相关的输入组件 placeholder 常量
 */
export const MenuIptProps: IptPropsConstType = {
  id: {
    formItem: {label: '菜单 ID', path: MenuObjPropNameEnum.ID},
    ipt: {
      placeholder: '请输入菜单 ID',
      allowInput: CommonIptPropValConst.allowInput.onlyNumber,
    },
  },
  parentId: {
    formItem: {label: '父级菜单', path: MenuObjPropNameEnum.PARENT_ID},
    ipt: {
      placeholder: '请选择父级菜单',
      getOptions: () => useMenuStore().getMenuCascadeOptions(),
      expandTrigger: 'hover',
      showPath: true,
    },
  },
  type: {
    formItem: {label: '菜单类型', path: MenuObjPropNameEnum.TYPE},
    ipt: {
      placeholder: '请选择菜单类型',
      options: MenuTypeOptionsConst,
    },
  },
  name: {
    formItem: {label: '菜单名称', path: MenuObjPropNameEnum.NAME},
    ipt: {
      placeholder: '请输入菜单名称',
      maxlength: MenuIptLimit.NAME_MAX_LEN,
      allowInput: CommonIptPropValConst.allowInput.noSideSpace,
    },
  },
  pagePath: {
    select: {
      formItem: {label: '页面选择', path: MenuObjPropNameEnum.PAGE_PATH},
      ipt: {
        placeholder: '请选择菜单页面',
        options: PageOptionsConst,
      }
    },
    input: {
      formItem: {label: '页面路径', path: MenuObjPropNameEnum.PAGE_PATH},
      ipt: {
        placeholder: '请输入菜单页面路径',
        maxlength: MenuIptLimit.PAGE_PATH_MAX_LEN,
        allowInput: CommonIptPropValConst.allowInput.noSideSpace,
      }
    },
  },
  routeName: {
    formItem: {label: '路由名称', path: MenuObjPropNameEnum.ROUTE_NAME},
    ipt: {
      placeholder: '请输入路由名称',
      maxlength: MenuIptLimit.ROUTE_NAME_MAX_LEN,
      allowInput: CommonIptPropValConst.allowInput.noSideSpace,
    },
  },
  routePath: {
    formItem: {label: '路由路径', path: MenuObjPropNameEnum.ROUTE_PATH},
    ipt: {
      placeholder: '请输入路由路径',
      maxlength: MenuIptLimit.ROUTE_PATH_MAX_LEN,
      allowInput: CommonIptPropValConst.allowInput.noSideSpace,
    },
  },
  routeQuery: {
    formItem: {label: '路由参数', path: MenuObjPropNameEnum.ROUTE_QUERY},
    ipt: {
      subListLen: 2,
      placeholder: ['请输入参数名称', '请输入参数值'],
      inputProps: {
        allowInput: CommonIptPropValConst.allowInput.noSideSpace,
      },
    }
  },
  linkPath: {
    formItem: {label: '链接地址', path: MenuObjPropNameEnum.LINK_PATH},
    ipt: {
      placeholder: '请输入链接地址',
      allowInput: CommonIptPropValConst.allowInput.noSideSpace,
    },
  },
  iconType: {
    formItem: {label: '图标类型', path: MenuObjPropNameEnum.ICON_TYPE},
    ipt: {
      placeholder: '请选择图标类型',
      options: MenuIconTypeOptions,
    }
  },
  icon: {
    formItem: {label: '图标', path: MenuObjPropNameEnum.ICON},
    ipt: {
      placeholder: '请输入图标',
      allowInput: CommonIptPropValConst.allowInput.noSideSpace,
    },
  },
  sort: {
    formItem: {label: '菜单排序', path: MenuObjPropNameEnum.SORT,},
    ipt: {
      placeholder: '请输入菜单排序',
      min: 0,
      max: Number.MAX_SAFE_INTEGER,
      allowInput: CommonIptPropValConst.allowInput.onlyNumber,
    },
  },
  disabled: {
    switch: {
      formItem: {label: '菜单状态', path: MenuObjPropNameEnum.DISABLED},
      ipt: CommonSwitchIptTextConst.enabled,
    },
    select: {
      formItem: {label: '是否禁用', path: MenuObjPropNameEnum.DISABLED},
      ipt: {
        placeholder: '请选择禁用状态',
        options: CommonIptOptionsConst.disabled,
      },
    }
  },
  hidden: {
    switch: {
      formItem: {label: '隐藏菜单', path: MenuObjPropNameEnum.HIDDEN},
      ipt: CommonSwitchIptTextConst.showed,
    },
    select: {
      formItem: {label: '是否隐藏', path: MenuObjPropNameEnum.HIDDEN},
      ipt: {
        placeholder: '请选择隐藏状态',
        options: CommonIptOptionsConst.hidden,
      },
    }
  },
  cached: {
    switch: {
      formItem: {label: '页面缓存', path: MenuObjPropNameEnum.CACHED},
      ipt: {}
    },
    select: {
      formItem: {label: '页面缓存', path: MenuObjPropNameEnum.CACHED},
      ipt: {
        placeholder: '请选择页面缓存状态',
        options: CommonIptOptionsConst.cached,
      },
    }
  },
  labeled: {
    select: {
      formItem: {label: '页面标签页', path: MenuObjPropNameEnum.LABELED},
      ipt: {
        placeholder: '请选择页面标签页状态',
        options: CommonIptOptionsConst.opened,
      },
    },
    switch: {
      formItem: {label: '页面标签页', path: MenuObjPropNameEnum.LABELED},
      ipt: {}
    }
  },
  labelSort: {
    formItem: {label: '标签页排序', path: MenuObjPropNameEnum.LABEL_SORT},
    ipt: {
      placeholder: '请输入标签页排序',
      min: 0,
      max: Number.MAX_SAFE_INTEGER,
      allowInput: CommonIptPropValConst.allowInput.onlyNumber,
    },
  },
}
